<?php


namespace api\console\controllers;


use api\components\GeoService;
use api\modules\app\models\Unit;
use yii\console\Controller;

class TestController extends Controller
{
    public function actionT9() {
        $count = 0;
        $models = Unit::find()->where(['street_code'=>''])->orderBy(['id' => SORT_DESC])->all();
print_r(count($models));exit;
        foreach ($models as $model) {
            $info = GeoService::getAreaByCoord(['lng'=>$model->lng,'lat'=>$model->lat]);
            print_r($info);exit;
//            $model->district_code = $info['区代码'];
            $model->street_code = $info['街道代码'];
            $model->save();
            $count++;
        }

        echo $count;
        exit;
    }
}
